class Solution(object):
    def reformatNumber(self, number):
        q = ''
        for c in number:
            if c != ' ' and c != '-':
                q += c
        number = q
        n = len(number)
        t = ''
        m = n % 3
        k = n // 3
        if m == 1:
            m = 4
            k -= 1
        for i in range(k):
            t += number[3 * i: 3 * (i + 1)] + '-'
        if m == 0:
            return t[:-1]
        if m == 2:
            return t + number[-2:]
        if m == 4:
            return t + number[-4:-2] + '-' + number[-2:]
